package com.benio.ycfdisplayer.fresco;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.drawee.interfaces.DraweeHierarchy;
import com.facebook.drawee.view.DraweeView;

/**
 * Wrapper for DraweeView.
 * Created by benio on 2016/10/5.
 */
public class DraweeViewTarget extends FrescoViewTarget<DraweeView> {

    public DraweeViewTarget(@NonNull DraweeView view) {
        super(view);
    }

    @Override
    public final DraweeController getController() {
        DraweeView view = mView.get();
        return view != null ? view.getController() : null;
    }

    @Override
    public final void setController(@Nullable DraweeController draweeController) {
        DraweeView view = mView.get();
        if (view != null) {
            view.setController(draweeController);
        }
    }

    @Override
    public final DraweeHierarchy getHierarchy() {
        DraweeView view = mView.get();
        return view != null ? view.getHierarchy() : null;
    }

    @Override
    public final void setHierarchy(DraweeHierarchy hierarchy) {
        DraweeView view = mView.get();
        if (view != null) {
            view.setHierarchy(hierarchy);
        }
    }
}
